package com.yantong.pay.yfz.domain.pay;


import com.yantong.pay.yfz.domain.pay.domain.WechatH5.WechatH5Request;
import com.yantong.pay.yfz.domain.pay.domain.WechatH5.WechatH5Response;
import com.yantong.pay.yfz.domain.pay.domain.aliJSAPI.AliJSAPIRequest;
import com.yantong.pay.yfz.domain.pay.domain.aliJSAPI.AliJSAPIResponse;
import com.yantong.pay.yfz.domain.pay.domain.authentication.AuthenticationRequest;
import com.yantong.pay.yfz.domain.pay.domain.authentication.AuthenticationResponse;
import com.yantong.pay.yfz.domain.pay.domain.cancel.CancelApplyRequest;
import com.yantong.pay.yfz.domain.pay.domain.cancel.CancelApplyResponse;
import com.yantong.pay.yfz.domain.pay.domain.cashierPay.CashierRequest;
import com.yantong.pay.yfz.domain.pay.domain.cashierPay.CashierResponse;
import com.yantong.pay.yfz.domain.pay.domain.close.CloseApplyRequest;
import com.yantong.pay.yfz.domain.pay.domain.close.CloseApplyResponse;
import com.yantong.pay.yfz.domain.pay.domain.memberEnter.MemberEnterRequest;
import com.yantong.pay.yfz.domain.pay.domain.memberEnter.MemberEnterResponse;
import com.yantong.pay.yfz.domain.pay.domain.microPay.MicroPayRequest;
import com.yantong.pay.yfz.domain.pay.domain.microPay.MicroPayResponse;
import com.yantong.pay.yfz.domain.pay.domain.nativePay.NativePayRequest;
import com.yantong.pay.yfz.domain.pay.domain.nativePay.NativePayResponse;
import com.yantong.pay.yfz.domain.pay.domain.paymenQuery.PaymentQueryRequest;
import com.yantong.pay.yfz.domain.pay.domain.paymenQuery.PaymentQueryResponse;
import com.yantong.pay.yfz.domain.pay.domain.protocol.*;
import com.yantong.pay.yfz.domain.pay.domain.refund.RefundApplyRequest;
import com.yantong.pay.yfz.domain.pay.domain.refund.RefundApplyResponse;
import com.yantong.pay.yfz.domain.pay.domain.refundQuery.RefundApplyQueryRequest;
import com.yantong.pay.yfz.domain.pay.domain.refundQuery.RefundApplyQueryResponse;
import com.yantong.pay.yfz.domain.pay.domain.split.SplitRequest;
import com.yantong.pay.yfz.domain.pay.domain.split.SplitResponse;
import com.yantong.pay.yfz.domain.pay.domain.split.SplitResultQueryRequest;
import com.yantong.pay.yfz.domain.pay.domain.split.SplitResultQueryResponse;
import com.yantong.pay.yfz.domain.pay.domain.split.relation.*;
import com.yantong.pay.yfz.domain.pay.domain.splitRefund.RefundRequest;
import com.yantong.pay.yfz.domain.pay.domain.splitRefund.RefundResponse;
import com.yantong.pay.yfz.domain.pay.domain.union.UnionPayRequest;
import com.yantong.pay.yfz.domain.pay.domain.union.UnionPayResponse;
import com.yantong.pay.yfz.domain.pay.domain.wechatJSAPI.WechatJSAPIRequest;
import com.yantong.pay.yfz.domain.pay.domain.wechatJSAPI.WechatJSAPIResponse;
import com.yantong.pay.yfz.domain.pay.domain.withdraw.*;
import com.yantong.pay.yfz.util.Config;
import com.yantong.pay.yfz.util.RemoteInvoker;

import java.util.Map;

public class PaymentHelper {

    /**
     * 支付宝服务窗支付
     * @param request 订单内容
     * @throws Exception
     */
    public static AliJSAPIResponse aliJSAPIPay(AliJSAPIRequest request,String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception{
        return RemoteInvoker.invoke(request, Config.getAliJSAPIUrl(),yplPrivateKey,yplPrivateKeyPwd,yplSignNo,publicKeyFileUri,  AliJSAPIResponse.class);
    }

    /**
     * 微信公众号支付
     * @param request 订单内容
     * @throws Exception
     */
    public static WechatJSAPIResponse wechatJSAPIPay(WechatJSAPIRequest request,String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception{
        return RemoteInvoker.invoke(request, Config.getWechatJSAPIUrl(),yplPrivateKey,yplPrivateKeyPwd,yplSignNo,publicKeyFileUri,  WechatJSAPIResponse.class);
    }

    /**
     * 微信H5支付
     * @param request 订单内容
     * @throws Exception
     */
    public static WechatH5Response wechatH5Pay(WechatH5Request request,String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception{
        return RemoteInvoker.invoke(request, Config.getWechatH5Url(),yplPrivateKey,yplPrivateKeyPwd,yplSignNo,publicKeyFileUri,  WechatH5Response.class);
    }

    /**
     * 主掃支付
     * @param request 订单内容
     * @throws Exception
     */
    public static NativePayResponse nativePay(NativePayRequest request, String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception{
        return RemoteInvoker.invoke(request, Config.getNativePayUrl(),yplPrivateKey,yplPrivateKeyPwd,yplSignNo,publicKeyFileUri,  NativePayResponse.class);
    }

    /**
     * 被掃支付
     * @param request 订单内容
     * @throws Exception
     */
    public static MicroPayResponse microPay(MicroPayRequest request,String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception{
        return RemoteInvoker.invoke(request, Config.getScaningURL(),yplPrivateKey,yplPrivateKeyPwd,yplSignNo,publicKeyFileUri,  MicroPayResponse.class);
    }

    /**
     * 預下單支付/收銀檯支付
     * @param request 订单内容
     * @throws Exception
     */
    public static CashierResponse cashierPay(CashierRequest request,String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception{
        return RemoteInvoker.invoke(request, Config.getCashierPayUrl(),yplPrivateKey,yplPrivateKeyPwd,yplSignNo,publicKeyFileUri,  CashierResponse.class);
    }

    /**
     * 支付结果查询
     * @param request 订单内容
     * @throws Exception
     */
    public static PaymentQueryResponse paymentQuery(PaymentQueryRequest request, String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception{
        return RemoteInvoker.invoke(request, Config.getPaymentQueryUrl(),yplPrivateKey,yplPrivateKeyPwd,yplSignNo,publicKeyFileUri,  PaymentQueryResponse.class);
    }
    //------------------退款----------------
    /**
     * 退款申请
     * @param request 订单内容
     * @throws Exception
     */

    public static RefundApplyResponse refundApply(RefundApplyRequest request, String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception{
        return RemoteInvoker.invoke(request, Config.getRefundApplyUrl(),yplPrivateKey,yplPrivateKeyPwd,yplSignNo,publicKeyFileUri,  RefundApplyResponse.class);
    }
    
    /**
     * 退款查询
     * @param request 订单内容
     * @throws Exception
     */
    public static RefundApplyQueryResponse refundQuery(RefundApplyQueryRequest request,String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception{
        return RemoteInvoker.invoke(request, Config.getRefundQueryUrl(),yplPrivateKey,yplPrivateKeyPwd,yplSignNo,publicKeyFileUri,  RefundApplyQueryResponse.class);
    }

    /**
     * 退款
     * @param request 订单内容
     * @throws Exception
     */
    public static RefundResponse refund(RefundRequest request,String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception{
        return RemoteInvoker.invoke(request, Config.getRefundUrl(),yplPrivateKey,yplPrivateKeyPwd,yplSignNo,publicKeyFileUri,  RefundResponse.class);
    }

    //------------------分账----------------
    /**
     * 分账
     * @param request 订单内容
     * @throws Exception
     */
    public static SplitResponse split(SplitRequest request,String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception{
        return RemoteInvoker.invoke(request, Config.getSplitPayUrl(),yplPrivateKey,yplPrivateKeyPwd,yplSignNo,publicKeyFileUri,  SplitResponse.class);
    }
    
    /**
     * 分账查询
     * @param request 订单内容
     * @throws Exception
     */
    public static SplitResultQueryResponse splitResultQuery(SplitResultQueryRequest request,String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception{
        return RemoteInvoker.invoke(request, Config.getSplitResultQueryURL(),yplPrivateKey,yplPrivateKeyPwd,yplSignNo,publicKeyFileUri,  SplitResultQueryResponse.class);
    }
    //------------------提现----------------
    /**
     * 会员现
     * @param request 订单内容
     * @throws Exception
     */
    public static Withdraw4SubMerchantResponse withdraw4member(MemberWithdrawRequest request, String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception{
        return RemoteInvoker.invoke(request, Config.getWithdraw4Member(),yplPrivateKey,yplPrivateKeyPwd,yplSignNo,publicKeyFileUri,  Withdraw4SubMerchantResponse.class);
    }
    
    /**
     * 子商户提现
     * @param request 订单内容
     * @throws Exception
     */
    public static Withdraw4SubMerchantResponse withdraw4SubMerchant(Withdraw4SubMerchantRequest request, String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception{
        return RemoteInvoker.invoke(request, Config.getWithdraw4SubMerchantUrl(),yplPrivateKey,yplPrivateKeyPwd,yplSignNo,publicKeyFileUri,  Withdraw4SubMerchantResponse.class);
    }
    /**
     * 子商户提现查询
     * @param request 订单内容
     * @throws Exception
     */
    public static WithdrawQuery4SubMerchantResponse withdrawQuery4SubMerchant(WithdrawQuery4SubMerchantRequest request, String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception{
        return RemoteInvoker.invoke(request, Config.getWithdrawQuery4SubMerchantUrl(),yplPrivateKey,yplPrivateKeyPwd,yplSignNo,publicKeyFileUri,  WithdrawQuery4SubMerchantResponse.class);
    }
    /**
     * 单笔代付
     * @param request 订单内容
     * @throws Exception
     */
    public static WithdrawToCardResponse withdrawalToCard(WithdrawToCardRequest request, String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception{
        return RemoteInvoker.invoke(request, Config.getWithdrawalToCardUrl(),yplPrivateKey,yplPrivateKeyPwd,yplSignNo,publicKeyFileUri,  WithdrawToCardResponse.class);
    }
    
    /**
     * 网银支付
     * @param request 订单内容
     * @throws Exception
     */
    public static UnionPayResponse unionPay(UnionPayRequest request,String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception{
        return RemoteInvoker.invoke(request, Config.getUnionPayUrl(),yplPrivateKey,yplPrivateKeyPwd,yplSignNo,publicKeyFileUri,  UnionPayResponse.class);
    }
    
    /**
     * 单笔代付查询
     * @param request 订单内容
     * @throws Exception
     */
    public static WithdrawToCardQueryResponse withdrawalToCardQuery(PaymentQueryRequest request, String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception{
        return RemoteInvoker.invoke(request, Config.getWithdrawalToCardQueryUrl(),yplPrivateKey,yplPrivateKeyPwd,yplSignNo,publicKeyFileUri,  WithdrawToCardQueryResponse.class);
    }
    
    /**
     * 余额查询
     * @param request 订单内容
     * @throws Exception
     */
    public static CustomerAccountQueryResp accountQuery(Map<String, String> request, String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception{
        return RemoteInvoker.invoke(request, Config.getAccountQueryUrl(),yplPrivateKey,yplPrivateKeyPwd,yplSignNo,publicKeyFileUri,  CustomerAccountQueryResp.class);
    }
    
    /**
     * 协议支付绑卡预交易
     * @param request 订单内容
     * @throws Exception
     */
    public static ProtocolPayBindCardResponse bindCard(ProtocolPayBindCardRequest request,String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception{
        return RemoteInvoker.invoke(request, Config.getBindCardUrl(),yplPrivateKey,yplPrivateKeyPwd,yplSignNo,publicKeyFileUri,  ProtocolPayBindCardResponse.class);
    }
    
    /**
     * 协议支付绑卡确认
     * @param request 订单内容
     * @throws Exception
     */
    public static ProtocolPayBindCardConfirmResponse bindCardConfirm(ProtocolPayBindCardConfirmRequest request,String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception{
        return RemoteInvoker.invoke(request, Config.getBindCardConfirmUrl(),yplPrivateKey,yplPrivateKeyPwd,yplSignNo,publicKeyFileUri,  ProtocolPayBindCardConfirmResponse.class);
    }
    
    /**
     * 协议支付预交易
     * @param request 订单内容
     * @throws Exception
     */
    public static ProtocolPayResponse protocolPayPre(ProtocolPayRequest request,String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception{
        return RemoteInvoker.invoke(request, Config.getProtocolPayPreUrl(),yplPrivateKey,yplPrivateKeyPwd,yplSignNo,publicKeyFileUri,  ProtocolPayResponse.class);
    }
    
    /**
     * 协议支付确认交易
     * @param request 订单内容
     * @throws Exception
     */
    public static ProtocolPayConfirmResponse protocolPayConfirm(ProtocolPayConfirmRequest request,String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception{
        return RemoteInvoker.invoke(request, Config.getProtocolPayConfirmUrl(),yplPrivateKey,yplPrivateKeyPwd,yplSignNo,publicKeyFileUri,  ProtocolPayConfirmResponse.class);
    }
    
    /**
     * 协议支付解绑
     * @param request 订单内容
     * @throws Exception
     */
    public static ProtocolPayBindCardResponse unBindCard(ProtocolPayUnbindCardRequest request,String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception{
        return RemoteInvoker.invoke(request, Config.getUnBindCardUrl(),yplPrivateKey,yplPrivateKeyPwd,yplSignNo,publicKeyFileUri,  ProtocolPayBindCardResponse.class);
    }
    
    /**
     * 协议查询
     * @param request 订单内容
     * @throws Exception
     */
    public static ProtocolQueryResponse protocolQuery(ProtocolQueryRequest request,String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception{
        return RemoteInvoker.invoke(request, Config.getProtocolQuery(),yplPrivateKey,yplPrivateKeyPwd,yplSignNo,publicKeyFileUri,  ProtocolQueryResponse.class);
    }
    
    /**
     * 银行卡鉴权
     * @param order 订单内容
     * @throws Exception
     */
    public static AuthenticationResponse authentication(AuthenticationRequest order,String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception{
        return RemoteInvoker.invoke(order, Config.getAuthenticationUrl(),yplPrivateKey,yplPrivateKeyPwd,yplSignNo,publicKeyFileUri,  AuthenticationResponse.class);
    }   
    
    
    /**
     * 撤销订单
     * @param order 撤销订单
     * @throws Exception
     */
    public static CancelApplyResponse cancel(CancelApplyRequest order,String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception{
        return RemoteInvoker.invoke(order, Config.getCancelApplyUrl(),yplPrivateKey,yplPrivateKeyPwd,yplSignNo,publicKeyFileUri,  CancelApplyResponse.class);
    } 
    
        /**
     * 关闭订单
     * @param order 撤销订单
     * @throws Exception
     */
    public static CloseApplyResponse close(CloseApplyRequest order,String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception{
        return RemoteInvoker.invoke(order, Config.getCloseApplyUrl(),yplPrivateKey,yplPrivateKeyPwd,yplSignNo,publicKeyFileUri,  CloseApplyResponse.class);
    }    
    /**
     * 分账关系创建
     * @param request 分账关系创建
     * @throws Exception
     */
    public static SplitRelationResponse splitRelationAdd(SplitRelationAddRequest request,String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception{
        return RemoteInvoker.invoke(request, Config.getSplitRelationAddUrl(),yplPrivateKey,yplPrivateKeyPwd,yplSignNo,publicKeyFileUri,  SplitRelationResponse.class);
    }
    /**
     * 分账关系查询
     * @param request 分账关系查询
     * @throws Exception
     */
    public static SplitRelationQueryResponse splitRelationQuery(SplitRelationQueryRequest request,String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception{
        return RemoteInvoker.invoke(request, Config.getSplitRelationQueryUrl(),yplPrivateKey,yplPrivateKeyPwd,yplSignNo,publicKeyFileUri,  SplitRelationQueryResponse.class);
    }
    /**
     * 分账关系修改
     * @param request 分账关系修改
     * @throws Exception
     */
    public static SplitRelationResponse splitRelationUpdate(SplitRelationUpdateRequest request,String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception{
        return RemoteInvoker.invoke(request, Config.getSplitRelationUpdateUrl(),yplPrivateKey,yplPrivateKeyPwd,yplSignNo,publicKeyFileUri,  SplitRelationResponse.class);
    }
    /**
     * 分账子商户入驻
     * @param request 分账子商户入驻
     * @throws Exception
     */
    public static MemberEnterResponse memberEnter(MemberEnterRequest request,String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception{
        return RemoteInvoker.invoke(request, Config.getMemberEnterUrl(),yplPrivateKey,yplPrivateKeyPwd,yplSignNo,publicKeyFileUri,  MemberEnterResponse.class);
    }
    
    
}

